package com.project.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("cookie")
public class CookieController {

    @RequestMapping("test")
    public String cookieTest(HttpServletResponse resp){
        //向客户端发送cookie信息，默认放在客户端浏览器的缓存中
        resp.addCookie(new Cookie("aaa","111"));
        //设置了过期时间。cookie信息，存放在客户端的文件中
        Cookie cookie = new Cookie("bbb","222");
        cookie.setMaxAge(60);
        resp.addCookie(cookie);
        return "ok";
    }
}
